home *** CD-ROM | disk | FTP | other *** search
/ MacFormat 1996 June / macformat-038.iso / Demos / Interactive Wave / _DATAS / SHARED.Dxr / 00991_Gestion de l'hyperText.ls < prev    next >
Encoding:
Text File  |  1995-08-06  |  3.0 KB  |  111 lines

  1. on SetHT listPara, Op
  2.   global listHT
  3.   if (paramCount() <> 2) or (listHT = list()) then
  4.     set listHT to list(0, 0, 0)
  5.   end if
  6.   set Pz to 2
  7.   repeat with compt = 1 to count(listPara) / 4
  8.     add(listHT, getAt(listPara, Pz))
  9.     add(listHT, getAt(listPara, Pz + 1))
  10.     set NumCast to getAt(listPara, Pz + 2)
  11.     if stringp(NumCast) then
  12.       set NumCast to the number of cast NumCast
  13.     end if
  14.     add(listHT, NumCast)
  15.     add(listHT, getAt(listPara, Pz + 3))
  16.     set Pz to Pz + 4
  17.   end repeat
  18.   setAt(listHT, 1, count(listHT) / 4)
  19.   setAt(listHT, 3, getAt(listPara, 1))
  20. end
  21.  
  22. on AjouteHT listPara
  23.   SetHT(listPara, 1)
  24. end
  25.  
  26. on KillHT
  27.   global listHT
  28.   set listHT to list()
  29. end
  30.  
  31. on GetLastHTfound
  32.   global listHT
  33.   return getAt(listHT, getAt(listHT, 2) * 4)
  34. end
  35.  
  36. on GetLastNumHTfound
  37.   global listHT
  38.   return getAt(listHT, 2)
  39. end
  40.  
  41. on ClicHT
  42.   global listHT
  43.   if listHT = list() then
  44.     exit
  45.   end if
  46.   set PisteCast to getAt(listHT, 3)
  47.   if PisteCast <> 0 then
  48.     puppetSprite(PisteCast, 1)
  49.     set the castNum of sprite PisteCast to -1
  50.   end if
  51.   set PisteClic to the clickOn
  52.   if PisteClic = 0 then
  53.     exit
  54.   end if
  55.   set NumCast to the castNum of sprite PisteClic
  56.   if the castType of cast NumCast <> #text then
  57.     exit
  58.   end if
  59.   set Champs to the text of cast NumCast
  60.   set NumWord to the mouseWord
  61.   if NumWord = -1 then
  62.     exit
  63.   end if
  64.   set LastWord to word NumWord of Champs
  65.   set NumChar to the mouseChar
  66.   set Pz to 4
  67.   repeat with compt = 1 to getAt(listHT, 1)
  68.     if (offset(LastWord, getAt(listHT, Pz)) <> 0) or (offset(LastWord & "s", getAt(listHT, Pz)) <> 0) then
  69.       set TextCible to getAt(listHT, Pz)
  70.       set LenTC to length(TextCible)
  71.       set ChampsTest to char NumChar - LenTC to NumChar + LenTC of Champs
  72.       set PosDeb to offset(TextCible, ChampsTest)
  73.       if PosDeb <> 0 then
  74.         set OpOk to 1
  75.         if the number of words in TextCible <> 1 then
  76.           set Deca to PosDeb - 1
  77.           repeat with X = 1 to the number of chars in TextCible
  78.             if char X of TextCible <> char Deca + X of ChampsTest then
  79.               set OpOk to 0
  80.               exit repeat
  81.             end if
  82.           end repeat
  83.         end if
  84.         if OpOk = 1 then
  85.           setAt(listHT, 2, compt)
  86.           set CastAff to getAt(listHT, Pz + 2)
  87.           if CastAff <> -1 then
  88.             set ParaPos to getAt(listHT, Pz + 3)
  89.             if ParaPos <> "#" then
  90.               set PosX to value(word 1 of ParaPos)
  91.               set PosY to value(word 2 of ParaPos)
  92.               if offset("Mouse", ParaPos) <> 0 then
  93.                 set PosX to PosX + the mouseH
  94.                 set PosY to PosY + the mouseV
  95.               end if
  96.               set the locH of sprite PisteCast to PosX
  97.               set the locV of sprite PisteCast to PosY
  98.             end if
  99.             set the castNum of sprite PisteCast to CastAff
  100.           end if
  101.           set NomMacro to getAt(listHT, Pz + 1)
  102.           if NomMacro <> "#" then
  103.             CallM(NomMacro)
  104.           end if
  105.         end if
  106.       end if
  107.     end if
  108.     set Pz to Pz + 4
  109.   end repeat
  110. end
  111.